/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pluginFonctions;

import java.util.ArrayList;

/**
 *
 * @author mazid
 */
public class FunctionProcessor{
    
    public FunctionProcessor() {
        
        
    }
    public double calculer(String functionName, ArrayList<Double> valeurs ) {
        Function function = null;
    
        double[] doubleVals = new double[valeurs.size()];;
        
        int i = 0;
        while (i < doubleVals.length) {
            doubleVals[i] = valeurs.get(i);
            i++;
        }
        
        if (functionName.equalsIgnoreCase("somme")) {
            function = new Somme();
        }
        else if(functionName.equalsIgnoreCase("moyenne")) {
            function = new Moyenne();
        }
        else {
            throw new UnsupportedOperationException("Function non supportée");
        }
        return function.calculer(doubleVals);
    }
    
}
